package com.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author sithum
 */
public class ResourceLoader {

    private static ResourceLoader loader;
    private static Properties properties;

    private ResourceLoader() {
    }

    public static synchronized ResourceLoader getInstance() {
        if (loader == null) {
            loader = new ResourceLoader();
            ResourceLoader.loadProperties();
        }
        return loader;
    }

    private static void loadProperties() {
        InputStream input = ResourceLoader.class.getResourceAsStream("resources/Resources.properties");
        try {
            System.out.println(input.available());
            ResourceLoader.properties = new Properties();
            ResourceLoader.properties.load(input);
        } catch (IOException ex) {
            Logger.getLogger(ResourceLoader.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public String getProperty(Object key) {
        return properties.getProperty(key.toString());
    }
}
